package com.torry.edss.api.controller;

import com.torry.edss.integration.facade.RemoteApiFacade;
import com.torry.edss.integration.facade.enums.Direction;
import com.torry.edss.integration.facade.result.*;
import com.torry.edss.integration.feign.tushare.TuShareFeignClient;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("/remoteApi")
@Api(tags = "远程API测试")
public class FacadeController {


    @Resource
    private RemoteApiFacade remoteApiFacade;
    @Resource
    private TuShareFeignClient tuShareFeignClient;

    @GetMapping("fetchAllStocks")
    List<FetchAllStocksResult> fetchAllStocks() {
        return remoteApiFacade.fetchAllStocks();
    }

    @GetMapping("fetchRealTimeDailyLines/{code}")
    List<FetchDailyLineResult> fetchRealTimeDailyLines(@PathVariable String code) {
        return remoteApiFacade.fetchAllDailyLines(code);
    }

    @GetMapping("fetchStockLDate/{code}")
    LocalDate fetchStockLDate(@PathVariable String code) {
        return remoteApiFacade.fetchStockLDate(code);
    }

    @GetMapping("fetchLimitUps/{date}")
    List<FetchLimitUpResult> fetchLimitUps(@PathVariable String date) {
        return remoteApiFacade.fetchLimitUps(date);
    }

    @GetMapping("fetchLimitDowns/{date}")
    List<FetchLimitDownResult> fetchLimitDowns(@PathVariable String date) {
        return remoteApiFacade.fetchLimitDowns(date);
    }

    @GetMapping("fetchLimitBombs/{date}")
    List<FetchLimitBombResult> fetchLimitBombs(@PathVariable String date) {
        return remoteApiFacade.fetchLimitBombs(date);
    }

    @GetMapping("fetchFundFlowInfo")
    List<FetchFundFlowInfoResult> fetchFundFlowInfo() {
        return remoteApiFacade.fetchFundFlowInfo();
    }

    @GetMapping("fetchRealTimeMarketData")
    FetchRealTimeMarketDataResult fetchRealTimeMarketData() {
        return remoteApiFacade.fetchRealTimeMarketData();
    }

    @GetMapping("fetchRealTimeTotalAmountChange/{previousDayTotalAmount}")
    Double fetchRealTimeTotalAmount(@PathVariable Double previousDayTotalAmount) {
        return remoteApiFacade.fetchRealTimeTotalAmount(previousDayTotalAmount);
    }

    @GetMapping("fetchRealTimeUpDownInfo")
    FetchUpDownInfoResult fetchRealTimeUpDownInfo() {
        return remoteApiFacade.fetchRealTimeUpDownInfo();
    }

    @GetMapping("fetchPreviousDayLine/{code}/{date}")
    FetchDailyLineResult fetchPreviousDayLine(@PathVariable String code, @PathVariable String date) {
        return remoteApiFacade.fetchPreviousDayLine(code, date);
    }

    @GetMapping("fetchNexDayLine/{code}/{date}")
    FetchDailyLineResult fetchNexDayLine(@PathVariable String code, @PathVariable String date) {
        return remoteApiFacade.fetchNexDayLine(code, date);
    }

    @GetMapping("fetchDayLine/{code}/{date}/{direction}")
    FetchDailyLineResult fetchDayLine(@PathVariable String code, @PathVariable String date, @PathVariable Direction direction) {
        return remoteApiFacade.fetchDayLine(code, date, direction);
    }


    @GetMapping("fetchData/{code}/{limit}")
    List<FetchDailyLineResult> fetchData(@PathVariable String code, @PathVariable Integer limit) {
        return remoteApiFacade.fetchHisDailyLines(code, limit);
    }

    @GetMapping("fetchAllStockKLinesByDate/{date}/{limit}")
    List<FetchDailyLineResult> fetchAllStockKLinesByDate(@PathVariable String date) {
        return remoteApiFacade.fetchHisDailyLines(date);
    }
}
